/**
 * 初始化主页
 */
"use strict";
define(function(require, exports, module) {
	var mui, com, pVue;
	exports.init = function(M) {
		mui = M[0], com = M[1];
		pVue = new Vue({
			el: '#vueModel',
			data: {
				user: {}, //用户信息
				sliderimgs: ['../img/shuijiao.jpg', '../img/muwu.jpg', '../img/cbd.jpg', '../img/yuantiao.jpg'], //首页顶部图片列表
				list: getItemList() //显示数据列表
			},
			methods: {
				itemTap: function() {
					mui.openWindow({
						url: '../page/course.html',
						id: 'page-course',
						//preload: true,
						show: {
							aniShow: 'slide-in-right'
						},
						waiting: {
							autoShow: false
						}
					});
				}
			}
		});
		mui.init({
			swipeBack: true //启用右滑关闭功能
		});
		var slider = mui("#slider");
		slider.slider({
			interval: 2000
		});
	}

	function getItemList() {
		var l = parseInt(Math.random() * 50),
			res = [];
		for(var i = 0; i < l; i++) {
			res.push({
				img: ['../img/shuijiao.jpg', '../img/muwu.jpg', '../img/cbd.jpg', '../img/yuantiao.jpg'][parseInt(Math.random() * 3)],
				title: ['杂交水稻种植', '农村小龙虾上半年水产养殖病虫防范', '螃蟹养殖', '水产配置'][parseInt(Math.random() * 3)],
				author: '袁隆平',
				grade: ['入门', '初级', '中级', '高级'][parseInt(Math.random() * 3)],
				comcnt: parseInt(Math.random() * 1000),
				likecnt: parseInt(Math.random() * 10000),
				updated_at: new Date().format('yyyy-MM-dd H:m')
			});
		}
		return res;
	}
});